<?php

$action = getAction();

switch ($action) {
	case "index":
			$loginId = trim($_POST['loginId']);
			$password = trim($_POST['password']);
			$yzm = strtoupper(trim($_POST['yzm']));

			if($yzm != $_SESSION['code']) 
			{
				errback('验证码出错！');
			}
			
			$c = $db->getOne("select count(1) from ".table('promoter')." where login_id='$loginId' ");
			if($c == 0)
			{
				errback('用户名或者密码出错！')	;
			}
			
			$ct=$db->getRow("select * from ".table('promoter')." where login_id='$loginId' and password='$password' ");
			$ip=$_SERVER['REMOTE_ADDR'];
			$dateline=time();

			if($ct)
			{
				$ct["last_login_time"] = getNowTime();
				$db->update("promoter", $ct, " and id = " . $ct["id"]);
								
				$_SESSION['web_cadmin'] = $rs = $ct;		
				$_SESSION['web_cadmin']['domain'] = $_SERVER["HTTP_HOST"];
				$_SESSION['web_cadmin']['promoter_id'] = $ct["id"];
				$_SESSION['web_cadmin']['login_id'] = $loginId;
				$logdesc="{$loginId}登陆成功！";
				
				gourl("cadmin.php?m=iframe");
			}else
			{
				errback('用户名或者密码出错！');
			}
			break;
}
?>